package com.cloud.stock.controller;

import com.cloud.common.entity.GoodsKuEntity;
import com.cloud.common.utils.R;
import com.cloud.stock.service.GoodsKuService;
import com.cloud.stock.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author luoJie
 * @email luoJie@gmail.com
 * @date 2020-10-04 16:40:24
 */
@RestController
@RequestMapping("stock/goodsku")
public class GoodsKuController {
    @Autowired
    private GoodsKuService goodsKuService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = goodsKuService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		GoodsKuEntity goodsKu = goodsKuService.getById(id);

        return R.ok().put("goodsKu", goodsKu);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody GoodsKuEntity goodsKu){
		goodsKuService.save(goodsKu);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody GoodsKuEntity goodsKu){
		goodsKuService.updateById(goodsKu);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ids){
		goodsKuService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
